package com.tkp.controller;

import com.tkp.entity.Author;
import com.tkp.entity.User;
import com.tkp.service.impl.IUserServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author: duk
 * @Date: 2021/10/27 15:24
 * @Description: 测试控制类
 */

@RestController
@Api("第一个接口文档")
public class HelloController {

    @Resource
    private Author author;
    @Resource
    private IUserServiceImpl iUserService;

    /**
     * hello
     * @return 用户名
     */
    @ApiOperation(value = "第一个信息", notes = "第一个信息", produces = "application/json")
    @RequestMapping(value = "/hello",method = RequestMethod.POST)
    public String hello(){
        return "用户名：" + author.getName() + ";地址：" + author.getCsdnUrl();
    }

    /**
     * 查询用户信息
     * @param userCode 用户编码
     * @return 用户信息
     */
    @ApiOperation(value = "用户信息查询", notes = "用户信息查询")
    @RequestMapping(value = "/getUser",method = RequestMethod.GET)
    public User getUser(@ApiParam("用户编码") String userCode){
        User user = new User();
        user.setUserCode(userCode);
        List<User> userList = iUserService.selectUser(user);
        return userList.get(0);
    }




}
